Wiki

Clone wiki

Rug.Osc / Iterate through message arguments

The OscMessage type acts as an object collection, to access the arguments contained in a message you have a couple of options.

#!c#

// create an message with 4 arguments
OscMessage message = new OscMessage("/foo", 1, 2, 3, 4);


// iterate over the default enumerator
foreach (object obj in message)
{
    Console.WriteLine(obj.ToString()); 
}


// access any argument by index
for (int i = 0; i < message.Count; i++)
{
    Console.WriteLine(message[i].ToString()); 
}


// access the arguments as an array 
object[] arguments = message.ToArray();

foreach (object obj in arguments)
{
    Console.WriteLine(obj.ToString()); 
}

Updated